package com.sun.commons.base;


import cn.hutool.core.util.StrUtil;
import com.sun.commons.utils.IdGenerator;
import com.sun.dto.BaseSearchModel;
import com.sun.dto.users.LoginUserDetails;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * MP自动填充Handler
 *
 * @Author sun
 * @CreateTime 2025/9/7 00:20
 */
@Service
public class BaseService {
    @Autowired
    private IdGenerator idGenerator;
    @PersistenceContext
    private EntityManager em;

    public Long nextId() {
        return idGenerator.next();
    }


    public LoginUserDetails getCurrentUser(){
        return (LoginUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }

}
